package com.itheima;

import com.itheima.pojo.Goods;
import com.itheima.repository.GoodsRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringDataEsEx {

    @Autowired
    private GoodsRepository goodsRepository;


    @Test
    public void findByPriceRang(){
        List<Goods> byPriceBetween = goodsRepository.findByPriceBetween(2701.00, 2703.00);
        for (Goods goods : byPriceBetween) {
            System.out.println("结果： " + goods);
        }
    }

    @Test
    public void findByIdAndTitle(){
        List<Goods> goodsList = goodsRepository.findByTitleAndId("小米", 2L);
        for (Goods goods : goodsList) {
            System.out.println("结果： " + goods);
        }
    }
}
